home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-01
/
cwl2f-3.zip
/
UPDATE.DOC
< prev
Wrap
Text File
|
1992-06-10
|
7KB
|
177 lines
Here are the last minute changes to The C Window Library manual:
Important Information for C++ users
-----------------------------------
If you are using the Zortech C++ or Borland C++ compilers, and you are using
the C++ compile option, here are some things to look out for:
- Declare any user-defined menu functions as functions with variable
arguments. If you have included window.h in your source file, you can
use the UNKNOWNARGS macro. Here is an example:
int menu_func(UNKNOWNARGS);
BAR_MENU_ENTRY bar_items[] = {
"File",1,4,'F',ALTF,menu_func,
"Edit",1,10,'E',0,menu_func,
/* Rest of definitions */
or if you are creating menus dynamically:
BarCreateEntry(menu_array,1,"File",1,4,'F',ALTF,menu_func);
The same thing applies to popup menus.
- The function body of the user defined menu functions MUST be located in a
different source file than the file where they were defined.
For example, FILE1.CPP contains the following:
int menu_func(UNKNOWNARGS);
BAR_MENU_ENTRY bar_items[] = {
"File",1,4,'F',ALTF,menu_func,
"Edit",1,10,'E',0,menu_func,
/* Rest of definitions */
Then you must have a file, say FILE2.CPP, with the following:
int menu_func(BAR_MENU_PTR, int);
int menu_func(BAR_MENU_PTR b, int sel)
{
/* Function body */
}
The reasons for this is that the definition for the user defined menu
function is a pointer to a function with an unknown number of arguments.
Therefore, C++ users must declare their user function as such or an error
will occur during compilation. To fool the compiler, we have declared all
of the user-defined menu functions as functions with an unknown number of
arguments in FILE1.CPP, and the body of the function is located in
FILE2.CPP with the passed arguments from the menu manager.
So far this method works with the TLINK linker for Turbo (Borland) C++, and
BLINK for the Zortech compiler. This method may not work with other linkers
out there that may do extensive type checking.
I will probably make changes in future versions to alleviate this problem
for C++ users.
CLICKING OR RELEASING THE MOUSE OUTSIDE OF A MENU
-------------------------------------------------
You can now define a function to perform when the mouse is clicked
or released outside of a popup, bar, or pulldown. The menu
must be created with the BARSETMOUSE or POPUPSETMOUSE menu options
for bar and popup menus, respectively.
Previously, when the mouse was clicked or released outside a menu
window, nothing occurred. There are quite a few menuing systems
where a mouse click outside a menu closes the menu. To make this
option as flexible as possible, a user defined function can be
called when a mouse click is detected outside a menu.
The BarSetClickFunction() and the PopupSetClickFunction() define
functions to be called when a mouse click or release is detected
outside a menu window.
The prototype for these two functions is as follows:
int BarSetClickFunction(BAR_MENU_PTR bar,
int (*func)(BAR_MENU_PTR b, int row,
int col, int selection))
int PopupSetClickFunction(POPUP_MENU_PTR popup,
int (*func)(POPUP_MENU_PTR p,
int row, int col,
int selection))
The first argument is the menu pointer to assign the function to.
The second argument is the pointer to the function that will be
called when a mouse click (or release) is detected outside the menu
window.
The first argument passed to the user-defined function is the menu
pointer. The second and third arguments are the row and column of
the mouse when it was pressed. The row and column are in absolute
screen coordinates, not mouse or window coordinates. The last
argument is the mouse button that was pressed. The value of this
constant is either MOUSELEFT_PRESS, MOUSERIGHT_PRESS or
MOUSEMIDDLE_PRESS depending on the button that was pressed or
released.
The user defined function MUST return a value back to the menu
manager. These return values are the same as the return values for
the menu undefined key functions (popup_undef_key or bar_undef_key).
Refer to the PROCESSING UNDEFINED KEYS section of the menu chapter
in the documentation for these return values.
For pulldown menus, you should call PopupSetClickFunction() for each
popup menu of the pulldown system. You should also use the same
function to call for each popup. You should also call
BarSetClickFunction() so that the pulldown menu can act on clicks
when the pulldown menu is currently at the bar menu level.
If you want to turn off the click function, use the
NO_BAR_CLICK_FUNC or NO_POPUP_CLICK_FUNC macro as the second
argument to PopupSetClickFunction() or BarSetClickFunction(),
respectively.
Example: BarSetClickFunction(bar,NO_BAR_CLICK_FUNC)
The return values of BarSetClickFunction() are the same as
BarSetMouse(). The return values of PopupSetClickFunction() are the
same as PopupSetMouse().
Example:
#include "cwlmouse.h"
#include "menu.h"
int popup_click_func(POPUP_MENU_PTR, int, int, int);
POPUP_MENU_PTR p;
main()
{
...
MouseInitializeSystem(/* arguments */);
p = PopupCreateMenu(/* create menu arguments */);
PopupSetOptions(p,POPUPMOUSE);
PopupSetClickFunction(p,popup_click_func);
...
}
int popup_click_function(POPUP_MENU_PTR pop, int row, int col,
int sel)
{
/* quit menu if mouse clicked ouside of menu */
return POPUP_ESCAPE;
}
The above example exits the popup menu when the mouse is clicked or
released outside of the menu window. If this were a pulldown menu
the return value to exit the pulldown menu would have been
POPUP_PULLDOWN_EXIT.